package gui;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;

@SuppressWarnings("serial")
public class ClientsServieceWorkerWindow extends JFrame {
	
	private JPanel contentPane;
	private JTable table;
	private JTextField reportSearchTextField;
	private JTextField complainTextField;
	private JTextField replayTextField;
	private DefaultTableModel reportTableModel;
	private JLabel lblResultSearch ;
	private JScrollPane scrollPane_1;
	private JScrollPane scrollPane;

	/**
	 * Create the frame.
	 */
	
	public ClientsServieceWorkerWindow() {
		
		setTitle("Client service Worker Window");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(250, 30, 800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		lblResultSearch = new JLabel("");
		lblResultSearch.setBounds(155, 97, 170, 16);
		contentPane.add(lblResultSearch);
		
		reportTableModel = new DefaultTableModel(null,new Object[]{"ReportID", "OrderID","ClientID","Status"});
		
		scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(47, 125, 454, 227);
		contentPane.add(scrollPane_1);
		scrollPane = new JScrollPane();
		scrollPane_1.setViewportView(scrollPane);
		table = new JTable(reportTableModel);
		scrollPane.setViewportView(table);
	
		JButton btnLogOut = new JButton("Log Out");
		btnLogOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				MainWindow mainWindowframe = new MainWindow();
				mainWindowframe.setVisible(true);
				dispose();
			}
		});
		btnLogOut.setBounds(625, 40, 117, 29);
		contentPane.add(btnLogOut);
		
		JButton btnClientsReports = new JButton("clients InHandling reports");
		btnClientsReports.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				}
				
		});
		btnClientsReports.setBounds(31, 40, 194, 29);
		contentPane.add(btnClientsReports);
		
		reportSearchTextField = new JTextField();
		reportSearchTextField.setBounds(356, 39, 134, 28);
		contentPane.add(reportSearchTextField);
		reportSearchTextField.setColumns(10);
		
		final JComboBox optionComboBox = new JComboBox();
		optionComboBox.setModel(new DefaultComboBoxModel(new String[] {"ReportID", "OrderID", "ClientID"}));
		optionComboBox.setBounds(237, 41, 117, 27);
		contentPane.add(optionComboBox);
		
		JButton btnSearch = new JButton("Search");
		btnSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
			}
		});
		btnSearch.setBounds(382, 67, 85, 29);
		contentPane.add(btnSearch);
		
		JLabel lblComplainText = new JLabel("Complain Text:");
		lblComplainText.setBounds(57, 364, 96, 16);
		contentPane.add(lblComplainText);
		
		complainTextField = new JTextField();
		complainTextField.setEditable(false);
		complainTextField.setEnabled(false);
		complainTextField.setBounds(47, 396, 454, 142);
		contentPane.add(complainTextField);
		complainTextField.setColumns(10);
		
		JButton btnRefund = new JButton("Refund");
		btnRefund.setBounds(535, 142, 96, 29);
		contentPane.add(btnRefund);
		btnRefund.setVisible(false);
		
		JButton btnCloseTheCase = new JButton("Close The Case WithOut refund");
		btnCloseTheCase.setBounds(535, 171, 233, 29);
		contentPane.add(btnCloseTheCase);
		btnCloseTheCase.setVisible(false);
		
		replayTextField = new JTextField();
		replayTextField.setBounds(535, 240, 244, 264);
		contentPane.add(replayTextField);
		replayTextField.setColumns(10);
		replayTextField.setVisible(false);
		
		final JButton btnSend = new JButton("Send");
		btnSend.setBounds(700, 509, 79, 29);
		contentPane.add(btnSend);
		btnSend.setVisible(false);
		
		JButton btnReply = new JButton("Reply");
		btnReply.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				replayTextField.setVisible(true);
				btnSend.setVisible(true);
			}
		});
		btnReply.setBounds(535, 200, 78, 29);
		contentPane.add(btnReply);
		
		btnReply.setVisible(false);

	}
	
	public void CleanList(){
		
		int counter = reportTableModel.getRowCount();
		while(counter!=0){
			reportTableModel.removeRow(counter-1);
			counter--;
		}
	}
}
